/**
 * ...
 * @author Krzysztof Rozalski
 */
#if !php #error #end
package hapi.facebook.externs;
import php.NativeArray;

extern class Facebook {

	static function __init__():Void {
        untyped __call__("require_once", "facebook.php");
    }
	
	public function new(config:NativeArray):Void;
	
	static var VERSION:String;
	
	public static var CURL_OPTS: {
		var CURLOPT_CONNECTTIMEOUT:Int;
		var CURLOPT_RETURNTRANSFER:Bool;
		var CURLOPT_TIMEOUT:Int;
		var CURLOPT_USERAGENT:String;
	};
	private static var DROP_QUERY_PARAMS:Array<String>;
	public static var DOMAIN_MAP:Dynamic;
	
	private var appId:String;
	private var apiSecret:String;
	private var session:Dynamic;
	private var sessionLoaded:Bool;
	private var cookieSupport:Bool;
	private var baseDomain:String;
	
	private static function generateSignature(params:Dynamic, secret:Dynamic):String;
	
	public function setAppId(appId:String):String;
	public function getAppId():String;
	public function setApiSecret(apiSecret:String):String;
	public function getApiSecret():String;
	public function setCookieSupport(cookieSupport:Bool):Bool;
	public function useCookieSupport():Bool;
	public function setBaseDomain(domain:String):String;
	public function getBaseDomain():String;
	public function setSession(?session:Dynamic = null, ?writeCookie:Bool = true):Facebook;
	public function getSession():Dynamic;
	public function getUser():String;
	public function getLoginUrl(?params:NativeArray):String;
	public function getLogoutUrl(?params:NativeArray):String;
	public function getLoginStatusUrl(?params:Dynamic):String;
	public function api(?args:Dynamic, ?method:String, ?params:Dynamic):Dynamic;

	private function _restserver(params:Dynamic):Dynamic;
	private function _graph(path:String, ?method:String = "GET", ?params:Dynamic):Dynamic;
	private function _oauthRequest(url:String, params:Dynamic):Dynamic;
	private function makeRequest(url:String, ?params:Dynamic, ?ch:Dynamic):Dynamic;
	private function getSessionCookieName():String;
	private function setCookieFromSession(?session:Dynamic):Void;
	private function validateSessionObject(session:Dynamic):Dynamic;
	private function getApiUrl(method:String):String;
	private function getUrl(name:String, ?path:String="", ?params:Dynamic):String;
	private function getCurrentUrl():String;
	
	private static function errorLog(msg:Dynamic):Void;
	private static function base64UrlDecode(input:String):String;
}